//
//  VisitorLoginView.swift
//  MyWeibo
//
//  Created by apple on 15/10/6.
//  Copyright © 2015年 LBL. All rights reserved.
//

import UIKit

protocol VisitorLoginViewDelegate: NSObjectProtocol {
    //注册
    func visitorWillRegister()
    //登陆
    func visitorWillLogin()

}

class VisitorLoginView: UIView {

    weak var visitorViewDelegate: VisitorLoginViewDelegate?
    
    @IBOutlet weak var smallIcon: UIImageView!
    
    @IBOutlet weak var iconView: UIImageView!
    
    @IBOutlet weak var tipLabel: UILabel!

    func setUIInfo(imageName name: String,tipText: String,isHome:Bool = false){
        iconView.image = UIImage(named: name)
        tipLabel.text = tipText
        smallIcon.hidden = !isHome
        if isHome {
            startAnimation()
        }
    }
    // MARK: 转动动画
    private func startAnimation(){
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        anim.repeatCount = MAXFLOAT
        anim.duration = 5
        anim.toValue = 2 * M_PI
        //当动画页面处于非活跃状态下默认会移除图层
        anim.removedOnCompletion = false
        smallIcon.layer.addAnimation(anim, forKey: nil)
    }
    
    
    
    @IBAction func registerAction(sender: AnyObject) {
        visitorViewDelegate?.visitorWillRegister()
    }
    
    @IBAction func loginAction(sender: AnyObject) {
        visitorViewDelegate?.visitorWillLogin()
    }
    
    
    
}
